#include "material.h"

Material::Material(){
	ambient[0] = 1.0;
	ambient[1] = 1.0;
	ambient[2] = 1.0;

    diffuse[0] = 0.6;
	diffuse[1] = 0.6;
	diffuse[2] = 0.6;

	specular[0] = 0.6;
	specular[1] = 0.6;
	specular[2] = 0.6;
}

Material::Material(double _ambient, double _diffuse, double _specular){
	ambient[0] = _ambient;
	ambient[1] = _ambient;
	ambient[2] = _ambient;

    diffuse[0] = _diffuse;
	diffuse[1] = _diffuse;
	diffuse[2] = _diffuse;

	specular[0] = _specular;
	specular[1] = _specular;
	specular[2] = _specular;
}

Material::Material(double _ambientR, double _ambientG, double _ambientB, double _diffuseR, double _diffuseG, double _diffuseB, double _specularR, double _specularG, double _specularB){
	ambient[0] = _ambientR;
	ambient[1] = _ambientG;
	ambient[2] = _ambientB;

    diffuse[0] = _diffuseR;
	diffuse[1] = _diffuseG;
	diffuse[2] = _diffuseB;

	specular[0] = _specularR;
	specular[1] = _specularG;
	specular[2] = _specularB;
}

Material::~Material(){
}

void Material::setAmbient(double _ambientR, double _ambientG, double _ambientB){
	ambient[0] = _ambientR;
	ambient[1] = _ambientG;
	ambient[2] = _ambientB;
}

const double* Material::getAmbient() const{
	return ambient;
}

const GLfloat* Material::getAmbientGL() const{
    GLfloat *result = new GLfloat[3];
    for(int i = 0; i < 3; i++){
        result[i] = (GLfloat)ambient[i];
    }
	return result;
}

void Material::setDiffuse(double _diffuseR, double _diffuseG, double _diffuseB){
	diffuse[0] = _diffuseR;
	diffuse[1] = _diffuseG;
	diffuse[2] = _diffuseB;
}

const double* Material::getDiffuse() const{
	return diffuse;
}

const GLfloat* Material::getDiffuseGL() const{
    GLfloat *result = new GLfloat[3];
    for(int i = 0; i < 3; i++){
        result[i] = (GLfloat)diffuse[i];
    }
	return result;
}

void Material::setSpecular(double _specularR, double _specularG, double _specularB){
	specular[0] = _specularR;
	specular[1] = _specularG;
	specular[2] = _specularB;
}

const double* Material::getSpecular() const{
	return specular;
}

const GLfloat* Material::getSpecularGL() const{
    GLfloat *result = new GLfloat[3];
    for(int i = 0; i < 3; i++){
        result[i] = (GLfloat)specular[i];
    }
	return result;
}
